package org.dtrd.modules.record.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.extern.slf4j.Slf4j;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.record.entity.bean.BloodBean;

import javax.persistence.*;
import java.text.ParseException;
import java.util.Date;

@Table(name = "dtrd_ent_rd_signin_blood_pressure")
@Slf4j
public class DtrdEntRdSigninBloodPressure {
    @Id
    @Column(name = "data_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type= IdType.AUTO)
    private Integer dataId;

    @Column(name = "patient_id")
    private Integer patientId;

    /**
     * 记录日期
     */
    @Column(name = "record_date")
    private Date recordDate;

    /**
     * 测量时间
     */
    @Column(name = "record_time")
    private Date recordTime;

    /**
     * 高压
     */
    @Column(name = "blood_pressure_high_pressure")
    private Integer bloodPressureHighPressure;

    /**
     * 低压
     */
    @Column(name = "blood_pressure_low_voltage")
    private Integer bloodPressureLowVoltage;

    /**
     * 心率
     */
    @Column(name = "blood_pressure_heart_rate")
    private Integer bloodPressureHeartRate;

    /**
     * 备注
     */
    @Column(name = "blood_pressure_remark")
    private String bloodPressureRemark;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "is_del")
    private Integer isDel;

    /**
     * 照片以 竖线 | 拼接
     */
    @Column(name = "record_photo")
    private String recordPhoto;

    /**
     * 时段:1-早,2-晚
     */
    @Column(name = "blood_pressure_type")
    private Integer bloodPressureType;

    /**
     * 记录类型, 0-打卡, 1-建档
     */
    private Integer bloodPressureRecordArchiveTag;

    public Integer getBloodPressureRecordArchiveTag() {
        return bloodPressureRecordArchiveTag;
    }

    public void setBloodPressureRecordArchiveTag(Integer bloodPressureRecordArchiveTag) {
        this.bloodPressureRecordArchiveTag = bloodPressureRecordArchiveTag;
    }

    /**
     * @return data_id
     */
    public Integer getDataId() {
        return dataId;
    }

    /**
     * @param dataId
     */
    public void setDataId(Integer dataId) {
        this.dataId = dataId;
    }

    /**
     * @return patient_id
     */
    public Integer getPatientId() {
        return patientId;
    }

    /**
     * @param patientId
     */
    public void setPatientId(Integer patientId) {
        this.patientId = patientId;
    }

    /**
     * 获取记录日期
     *
     * @return record_date - 记录日期
     */
    public Date getRecordDate() {
        return recordDate;
    }

    /**
     * 设置记录日期
     *
     * @param recordDate 记录日期
     */
    public void setRecordDate(Date recordDate) {
        this.recordDate = recordDate;
    }

    /**
     * 获取测量时间
     *
     * @return record_time - 测量时间
     */
    public Date getRecordTime() {
        return recordTime;
    }

    /**
     * 设置测量时间
     *
     * @param recordTime 测量时间
     */
    public void setRecordTime(Date recordTime) {
        this.recordTime = recordTime;
    }

    /**
     * 获取高压
     *
     * @return blood_pressure_high_pressure - 高压
     */
    public Integer getBloodPressureHighPressure() {
        return bloodPressureHighPressure;
    }

    /**
     * 设置高压
     *
     * @param bloodPressureHighPressure 高压
     */
    public void setBloodPressureHighPressure(Integer bloodPressureHighPressure) {
        this.bloodPressureHighPressure = bloodPressureHighPressure;
    }

    /**
     * 获取低压
     *
     * @return blood_pressure_low_voltage - 低压
     */
    public Integer getBloodPressureLowVoltage() {
        return bloodPressureLowVoltage;
    }

    /**
     * 设置低压
     *
     * @param bloodPressureLowVoltage 低压
     */
    public void setBloodPressureLowVoltage(Integer bloodPressureLowVoltage) {
        this.bloodPressureLowVoltage = bloodPressureLowVoltage;
    }

    /**
     * 获取心率
     *
     * @return blood_pressure_heart_rate - 心率
     */
    public Integer getBloodPressureHeartRate() {
        return bloodPressureHeartRate;
    }

    /**
     * 设置心率
     *
     * @param bloodPressureHeartRate 心率
     */
    public void setBloodPressureHeartRate(Integer bloodPressureHeartRate) {
        this.bloodPressureHeartRate = bloodPressureHeartRate;
    }

    /**
     * 获取备注
     *
     * @return blood_pressure_remark - 备注
     */
    public String getBloodPressureRemark() {
        return bloodPressureRemark;
    }

    /**
     * 设置备注
     *
     * @param bloodPressureRemark 备注
     */
    public void setBloodPressureRemark(String bloodPressureRemark) {
        this.bloodPressureRemark = bloodPressureRemark;
    }

    /**
     * @return create_time
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @param createTime
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @return is_del
     */
    public Integer getIsDel() {
        return isDel;
    }

    /**
     * @param isDel
     */
    public void setIsDel(Integer isDel) {
        this.isDel = isDel;
    }

    /**
     * 获取照片以 竖线 | 拼接
     *
     * @return record_photo - 照片以 竖线 | 拼接
     */
    public String getRecordPhoto() {
        return recordPhoto;
    }

    /**
     * 设置照片以 竖线 | 拼接
     *
     * @param recordPhoto 照片以 竖线 | 拼接
     */
    public void setRecordPhoto(String recordPhoto) {
        this.recordPhoto = recordPhoto;
    }

    public DtrdEntRdSigninBloodPressure() {}

    public DtrdEntRdSigninBloodPressure(BloodBean dto) {
        this.patientId = dto.getPatientId();
        this.bloodPressureType = dto.getRecordType();
        this.bloodPressureHighPressure = dto.getHigh();
        this.bloodPressureLowVoltage = dto.getLow();
        this.bloodPressureHeartRate = dto.getHeart();
        this.recordPhoto = dto.getRecordPhoto();
        this.bloodPressureRemark = dto.getRemark();
        String time = dto.getTime();
        try {
            this.recordDate = DateUtils.parseDate(time, DateUtils.date_sdf.get().toPattern());
            this.recordTime = DateUtils.parseDate(time, DateUtils.datetimeFormat.get().toPattern());
        } catch (ParseException e) {
            log.error("DtrdEntRdSigninBloodPressure 构造参数 BloodBean 时间格式错误: " + time);
            e.printStackTrace();
        }
    }

    public DtrdEntRdSigninBloodPressure init(){
        this.isDel=0;
        createTime = new Date();
        return this;
    }

    public DtrdEntRdSigninBloodPressure buildWithParams(Integer highPressures, Integer lowPressure, Integer heartPulse){
        bloodPressureHighPressure=highPressures;
        bloodPressureLowVoltage=lowPressure;
        bloodPressureHeartRate=heartPulse;
        return this;
    }

    public Integer getBloodPressureType() {
        return bloodPressureType;
    }

    public void setBloodPressureType(Integer bloodPressureType) {
        this.bloodPressureType = bloodPressureType;
    }
}